package model;

import java.util.Collection;
import java.util.HashSet;
import java.util.Vector;

public class TransitionSet {

	private final HashSet<Transition> transitions;
	/**
	 * Constructor of {@link TransitionSet}.
	 */
	public TransitionSet() {
		this.transitions = new HashSet<Transition>();
	}
	/**
	 * Adds a {@link Transition} to this {@link TransitionSet} when the provided {@link Transition} is not yet in this 
	 * {@link TransitionSet}.
	 * @param transition is the {@link Transition} that is added.
	 */
	public void add(final Transition transition) {
		this.transitions.add(transition);
	}
	/**
	 * 
	 * @param from
	 * @param input
	 * @return
	 */
	public Collection<Transition> getAllFromWith(final State from, final char input){
		final Collection<Transition> result = new Vector<Transition>();
		for(final Transition transition : this.transitions){
			if(transition.getFrom() == from && transition.getInput() == input){
				result.add(transition);
			}
		}
		return result;
	}
}
